package cn.pn.project.controller;

import cn.pn.project.client.commodity.ShowtypeFeign;
import cn.pn.project.common.DtoUtil;
import cn.pn.project.pojo.commodity.Showtype;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/type/p")
public class ItemTypeController {

    @Autowired
    private ShowtypeFeign showtypeFeign;

    @RequestMapping(value = "/listAll",method = RequestMethod.GET)
    public Object listAllType(){
        System.out.println("==============================================************************************");
       // return "successCallback("+ JSONObject.toJSONString(DtoUtil.returnDataSuccess(showtypeFeign.listAllType()))+")";
        return showtypeFeign.listAllType();
    }

    @RequestMapping(value = "/listChildTypeByFatherId",method = RequestMethod.POST)
    public List<Showtype> listChildTypeByFatherId(@RequestParam("fatherId") Integer fatherId){
        System.out.println("listChildTypeByFatherId+++++++++++++++++++++++++++---------");
        return showtypeFeign.listChildTypeByFatherId(fatherId);
    }

    @RequestMapping(value = "/getTypeNameByTypeId",method = RequestMethod.POST)
    String getTypeNameByTypeId(@RequestParam("typeId")Integer typeId){

        return JSON.toJSONString(showtypeFeign.getTypeNameByTypeId(typeId));
    }

}
